<?php

namespace common\model;

use think\model\RelationModel;

class OauthClientModel extends RelationModel
{
    //自动验证
    protected $_validate = [
        ['name', '', '', self::MUST_VALIDATE, 'require', self::MODEL_INSERT],//必须字段
        ['name', '1,128', '', self::EXISTS_VALIDATE, 'length'],
        ['active', [1, 0], '', self::EXISTS_VALIDATE, 'in'],
        ['app_key', '0,36', '', self::EXISTS_VALIDATE, 'length'],
        ['app_secret', '0,36', '', self::EXISTS_VALIDATE, 'length'],
        ['resource_ids', '0,255', '', self::EXISTS_VALIDATE, 'length'],
        ['scope', '0,36', '', self::EXISTS_VALIDATE, 'length'],
        ['grant_types', '0,80', '', self::EXISTS_VALIDATE, 'length'],
        ['register', [1, 0], '', self::EXISTS_VALIDATE, 'in'],
        ['register_api', '0,128', '', self::EXISTS_VALIDATE, 'length'],
        ['set_user_api', '0,128', '', self::EXISTS_VALIDATE, 'length'],
        ['role_api', '0,128', '', self::EXISTS_VALIDATE, 'length']
    ];

    // 自动完成
    protected $_auto = [
        ['app_key', 'auto_fill_md5_str', self::MODEL_INSERT, 'function'],
        ['app_secret', 'auto_fill_md5_str', self::MODEL_INSERT, 'function'],
        ['created', 'time', self::MODEL_INSERT, 'function'],
        ['uuid', 'create_uuid', self::MODEL_INSERT, 'function']
    ];
}
